%%% This m file is for transfering the data in continuous time into
%%% discrete years, which is good reference and used as the initial guesses
%%% in the discrete time model.


clear all
close all


load res_conti_full.mat

% # of the obervations in continuous time model
lengthf = length(tf);
lengthr = length(tr);

Tbar_0 = round(Tbar);
T0_0 = round(T0);

yearsf0 = 0:T0_0;
yearsr0 = T0_0+1:Tbar_0;


ppkf = csaps(tf,kf);
ppNf = csaps(tf,Nf);
ppSf = csaps(tf,Sf);
ppnf = csaps(tf,nf);
ppinvf = csaps(tf,invf);


ppkr = csaps(tr,kr);
ppHr = csaps(tr,Hr);
ppir = csaps(tr,invr);
ppjr = csaps(tr,jr);

kf0 = fnval(ppkf,yearsf0)';
Nf0 = fnval(ppNf,yearsf0)';
Sf0 = fnval(ppSf,yearsf0)';
nf0 = fnval(ppnf,yearsf0)';
if0 = fnval(ppinvf,yearsf0)';


kr0 = fnval(ppkr,yearsr0)';
Hr0 = fnval(ppHr,yearsr0)';
ir0 = fnval(ppir,yearsr0)';
jr0 = fnval(ppjr,yearsr0)';

pickrule = round(linspace(1,lengthf,T0_0))';
gf0 = g(pickrule);
gf0 = gf0(end:-1:1);



save initialV.mat yearsf0 yearsr0 kf0 Sf0 Nf0 if0 nf0 gf0 kr0 Hr0 ir0 jr0 T0_0 Tbar_0

